<template>
  <div>
    <a-tree
      defaultExpandAll
      :default-checked-keys="['河南']"
      checkable
      :tree-data="treeData"
      :replace-fields="replaceFields"
      @check="onCheck"
    />

    <a-descriptions title="基本信息">
      <a-descriptions-item label="姓名">
        <a @click="user">张三</a>
      </a-descriptions-item>
      <a-descriptions-item label="电话">1535225213</a-descriptions-item>
    </a-descriptions>
    <a-button type @click="btn">防抖</a-button>

    <a-select
      mode="multiple"
      style="width: 100%"
      placeholder="Please select"
      @change="handleChange"
      v-model="k"
    >
      <a-select-option v-for="(item, index) in list" :key="index">{{ item.name }}</a-select-option>
    </a-select>
    <div style="margin-top: 24px">
      <a-button type @click="selectAll">全选</a-button>
      <a-button type @click="clearAll">清除</a-button>
    </div>

    <a-input-search
      style="margin-top: 20px"
      placeholder="请输入部门名称按回车进行搜索"
      v-model="deportName"
      @pressEnter="onChange"
      allowClear
    />

    <a-card title="接收单位" :bordered="false" class="groupsobjects">
      <a-checkbox-group @change="onChangeUnit" v-model="checkedList">
        <a-row v-for="(item, index) in xsxcUnitNameList" :key="index">
          <a-col :span="24">
            <a-checkbox :value="item.name">{{ item.name }}</a-checkbox>
          </a-col>
        </a-row>
      </a-checkbox-group>
    </a-card>

    <a-tabs default-active-key="1" @change="callback" :tab-position="mode">
      <a-tab-pane key="1" tab="Tab 1">Content of Tab Pane 1</a-tab-pane>
      <a-tab-pane key="2" tab="Tab 2" force-render>Content of Tab Pane 2</a-tab-pane>
      <a-tab-pane key="3" tab="Tab 3">Content of Tab Pane 3</a-tab-pane>
    </a-tabs>

    <div class="input_video">
      <video-player
        class="video-player vjs-custom-skin"
        ref="videoPlayer"
        :playsinline="true"
        :options="playerOptions"
      ></video-player>
    </div>
  </div>
</template>
<script>
import { debounce } from "lodash";
const treeData = [
  {
    name: "第一巡视组",
    key: "第一巡视组",
    checkable: false,
    child: [
      {
        name: "北京",
        key: "北京",
        // child: [
        //   { name: "leaf", key: "0-0-0-0" },
        //   { name: "leaf", key: "0-0-0-1" },
        // ],
      },

      {
        name: "河南",
        key: "河南",
        // child: [
        //   { name: "leaf", key: "0-0-0-0" },
        //   { name: "leaf", key: "0-0-0-1" },
        // ],
      },

      //   {
      //     name: "parent 1-1",
      //     key: "0-0-1",
      //     child: [{ key: "0-0-1-0", name: "zcvc" }],
      //   },
    ],
  },
  {
    name: "第二巡视组",
    key: "第二巡视组",
    checkable: false,
    child: [
      {
        name: "山西",
        key: "山西",
      },
    ],
  },
];

export default {
  data() {
    return {
      mode: "left",
      deportName: "",
      checked: false,
      checkedList: [],
      xsxcUnitNameList: [
        { name: "卓望公司", id: "1" },
        { name: "香港公司", id: "2" },
        { name: "移动公司", id: "3" },
        { name: "联通公司", id: "4" },
        { name: "电信公司", id: "5" },
      ],
      treeData,
      replaceFields: {
        children: "child",
        title: "name",
      },
      list: [{ name: "李四" }, { name: "张三" }],
      k: [],
      playerOptions: {
        playbackRates: [0.5, 1.0, 1.5, 2.0], //可选择的播放速度
        autoplay: true, //如果true,浏览器准备好时开始回放。
        muted: false, // 默认情况下将会消除任何音频。
        loop: true, // 视频一结束就重新开始。
        preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
        language: "zh-CN",
        aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
        fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
        sources: [
          {
            type: "",
            src: "http://ivi.bupt.edu.cn/hls/btv2hd.m3u8", //视频地址，可以是本地路径也可以是url地址
          },
        ],
        poster: "", //你的封面地址
        width: "100%",
        height: "100%",
        notSupportedMessage: "此视频暂无法播放，请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
        controlBar: {
          timeDivider: true, //当前时间和持续时间的分隔符
          durationDisplay: true, //显示持续时间
          remainingTimeDisplay: false, //是否显示剩余时间功能
          fullscreenToggle: true, //全屏按钮
        },
      },
    };
  },

  mounted() {},

  methods: {
    getRemote: _.debounce(function () {
      console.log("9999999999999");
    }, 1000),
    btn() {
      this.getRemote();
    },
    onSelect(selectedKeys, info) {
      console.log("selected", selectedKeys, info, "------111111111");
    },
    onCheck(checkedKeys, info) {
      console.log("onCheck", checkedKeys, info, "------2222222222");
    },
    user() {
      alert("张三");
      console.log("李四");
      console.log("张三李四王五");
    },
    handleChange() {
      alert("建立");
    },
    onChange() {
      let searchName = [];
      debugger;
      searchName.push(this.deportName);
      this.checkedList = searchName;
    },
    selectAll() {
      let searchName = [];
      for (let index = 0; index < this.xsxcUnitNameList.length; index++) {
        const element = this.xsxcUnitNameList[index];
        searchName.push(element.name);
      }
      this.checkedList = searchName;
    },
    clearAll() {
      this.checkedList = [];
      this.deportName = "";
    },
    onChangeUnit(checkedValues) {
      this.checkedList = checkedValues;
    },
    callback() {
      console.log("111");
    },
  },
};
</script>

<style scoped>
.groupsobjects {
  width: 100%;
  height: 418px;
  overflow-y: auto;
  position: relative;
}
.input_video {
  width: 400px;
  height: 400px;
  margin: 0 auto;
}
</style>